The present invention relates to an encoder apparatus for compressing and encoding moving pictures in accordance with an algorithm complying with an MPEG standard.
MPEG standards are known as international video compression standards issued by Moving Picture Experts Group. The MPEG standards define a virtual decoder model (i.e., a video buffering verifier (VBV)) connected to the output of an encoder. This model includes a reception buffer (or a VBV buffer) and the number of bits of encoded data is defined to meet a constraint on the occupancy level of the VBV buffer, i.e., the VBV buffer should neither overflow or underflow.
The VBV buffer is supposed to operate under the following ideal conditions:
(1) The encoder and the VBV buffer should operate completely synchronously with each other; and
(2) Each picture should be decoded instantaneously and encoded data associated with each picture should be removed instantaneously from the VBV buffer.
The occupancy level of the VBV buffer can be obtained by subtracting the cumulative number of bits of the encoded data to be decoded by the decoder (i.e., the encoded data output from the encoder) from that of the data transmitted from the encoder to the decoder through a transmission line.
The overflow of the VBV buffer refers to a state where the occupancy level of the VBV buffer reaches its capacity before the encoded data is removed from the VBV buffer. The underflow of the VBV buffer refers to a state where the occupancy level of the VBV buffer is short of the bit number of the encoded data to be removed from the VBV buffer. The VBV buffer underflows when too large a number of bits are used to encode a picture.
If the VBV buffer has underflowed, then the cumulative bit number of the encoded data output from the encoder is greater than the cumulative bit number of the data transmitted. Thus, it is impossible to transmit all of the encoded data obtained. As a result, the data received at the decoder will miss part of the data needed for decoding. Accordingly, if the underflow is likely to occur, the underflow should be avoided by controlling the encoder in such a manner that a reduced number of bits will be used to encode a picture.
A picture to be encoded is divided into multiple sub-regions called xe2x80x9cmacroblocksxe2x80x9d, each consisting of 16xc3x9716 pixels. In the known encoder, if the VBV buffer is likely to underflow, then the number of bits used is controlled by changing the quantization step sizes for the macroblocks within the picture being encoded.
This control technique is hard to apply to a small-sized picture, i.e., a picture composed of a relatively small number of pixels, as is often subjected to MPEG-1 processing. This is because the number of macroblocks per picture is also small in that case. For example, 1620 macroblocks are included in a picture of a size of 720xc3x97576 pixels, while only 396 macroblocks are included in a picture of a size of 352xc3x97288 pixels. Accordingly, an excessive number of bits should be used to encode each picture, thus often causing the VBV buffer to underflow.
An object of the invention is providing an encoder apparatus that re-encodes pictures if necessary and if there is enough time for the apparatus to do the encoding such that all of the encoded data can be transmitted without missing any part of it.
An inventive encoder apparatus includes: an encoder for compressing and encoding multiple moving pictures and calculating the number of bits used to obtain encoded data by encoding each said picture to be encoded; original picture data storage for storing the pictures to be encoded thereon; encoded data storage for storing the encoded data thereon; and a bit number comparator for obtaining a threshold value of the number of bits available for each said picture to be encoded and determining whether or not the bit number exceeds the threshold value. If the encoder has determined that there will be enough time for the encoder to re-encode a current one of the pictures to be encoded before encoding of a next one of the pictures is started and if the comparator has found the bit number exceeding the threshold value, then the encoder re-encodes the current picture by changing encoding parameters in such a manner as to reduce the bit number.
According to the present invention, if there is enough time for the encoder to re-encode the current picture, then the number of bits used to encode the picture is reduced so as not to exceed the threshold value.
In one embodiment of the present invention, the threshold value is a number of bits that is defined to prevent a video buffering verifier (VBV) buffer from underflowing.
In such an embodiment, the number of bits is controllable in such a manner as to prevent the VBV buffer from underflowing, or to make the encoded data, output from the encoder apparatus, meet a bit number constraint.
In another embodiment of the present invention, the encoder performs variable-length encoding on the moving pictures.
In such an embodiment, the number of bits can be reduced easily by changing encoding parameters.
In still another embodiment, each said encoding parameter is changed to increase a quantization step size.
In this manner, the number of bits can be reduced just as intended so as not to exceed the threshold value.
In yet another embodiment, the inventive apparatus encodes the moving pictures in real time such that encoding of each said picture is completed within a time interval defined for the moving pictures.
In such an embodiment, the number of bits can be reduced if necessary to encode the pictures in real time.
In this particular embodiment, the encoder is allowed to re-encode the current picture to be encoded if the number of pixels included in the current picture is equal to or less than half of a maximum number of pixels that the encoder can process within the time interval.
In such an embodiment, a picture, composed of a small number of pixels, is selectively re-encoded. Thus, the number of bits used to encode the picture can be reduced.
In an alternative embodiment, the inventive apparatus further includes a counter for counting the number of times the encoder has encoded the current picture. If the number of pixels included in the current picture is equal to or less than 1/N (where N is an integer equal to or greater than three) of a maximum number of pixels that the encoder can process within the time interval and if the counter indicates that the current picture has been encoded less than N times, then the encoder is allowed to re-encode the current picture.
In such an embodiment, the encoding parameters can be changed little by little, and therefore, degradation in image quality, resulting from the reduction in number of bits used, can be minimized.
In this particular embodiment, the encoding parameters are changed such that a quantization step size is gradually increased until the current picture has been encoded Nxe2x88x921 times and that the quantization step size is maximized within an allowable range when the current picture is encoded for the Nth time.
In this manner, the degradation in image quality can be minimized while preventing the bit number from exceeding the threshold value.
In yet another embodiment, the encoder begins encoding by encoding one of the pictures that is to be encoded first a number of times.
In this manner, the picture to be encoded first can have its image quality improved while preventing the bit number from exceeding the threshold value.
In yet another embodiment, the encoder ends encoding by re-encoding one of the pictures that has been encoded last.
In this manner, the picture that has been encoded last can have its image quality improved while preventing the bit number from exceeding the threshold value.
An inventive encoding method includes the steps of: a) compressing and encoding multiple moving pictures; b) calculating the number of bits used to obtain encoded data by encoding each said picture to be encoded; c) obtaining a threshold value of the number of bits available for each said picture to be encoded; and d) determining whether or not the bit number exceeds the threshold value. If there is enough time to re-encode a current one of the pictures to be encoded before encoding of a next one of the pictures is started and if the bit number has been found exceeding the threshold value, then the current picture is re-encoded in the step a) by changing encoding parameters in such a manner as to reduce the bit number.
According to the present invention, if there is enough time to re-encode the current picture, then the number of bits used to encode the picture is reduced so as not to exceed the threshold value.